﻿@model List<WebEntities.Models.Framework.UIMenuItem>

@{
    ViewBag.Title = "网站管理平台_菜单项管理视图";
}

@(Html.X().Menu()
    .ID("Grid1CtxMenu")
    .Items(
        Html.X().MenuItem().Text("编辑菜单项").Icon(Icon.BookEdit)
            .DirectEvents(de =>
            {
                de.Click.Action = "EditMenuItemWindow";
                de.Click.ExtraParams.Add(new Parameter("itemId", "this.parentMenu.dataRecord.data.ItemID", ParameterMode.Raw));
            }),
            Html.X().MenuItem().Text("删除菜单项").Icon(Icon.Cross).Listeners(ls => ls.Click.Handler = "App.BtnDeleteSel.getEl().dom.click()")
    )
)

@Html.X().Hidden().ID("DeleteHint").Text("是否要删除选中的菜单项？")

@(Html.X().Viewport()
        .Layout("fit")
        .Items(
            Html.X().GridPanel()
                .ID("GridPanel1")
                .Title("主菜单管理视图")
                .Store(
                    Html.X().StoreForModel()
                        .AutoSync(true)
                        .PageSize(50)
                        .ShowWarningOnFailure(false)
                        .Proxy(proxy => proxy.Add(Html.X().AjaxProxy()
                            .Url(Url.Action("GetMenuItemsByPage"))
                            .Reader(Html.X().JsonReader().Root("data"))
                            .Writer(writer => new JsonWriter { AllowSingle = true, Root = "data" })
                            .API(api => { api.Destroy = Url.Action("DeleteMenuItem"); })
                        ))
                        .Listeners(ls => ls.Write.Fn = "ext.net.comjs.onGridChange")
                )
                .ColumnModel(
                    Html.X().RowNumbererColumn(),
                    Html.X().Column().DataIndex(Model, m => m.ItemID).Text("菜单项ID"),
                    Html.X().Column().DataIndex(Model, m => m.ItemName).Text("菜单项名称"),
                    Html.X().Column().DataIndex(Model, m => m.MenuName).Text("系统菜单"),
                    Html.X().Column().DataIndex(Model, m => m.ItemUrl).Text("菜单项链接"),
                    Html.X().Column().DataIndex(Model, m => m.MvcArea).Text("区域名称"),
                    Html.X().Column().DataIndex(Model, m => m.MvcCtrl).Text("控制器名称"),
                    Html.X().Column().DataIndex(Model, m => m.MvcAction).Text("Action名称"),
                    Html.X().Column().DataIndex(Model, m => m.ParentItemName).Text("上级菜单项"),
                    Html.X().DateColumn().DataIndex(Model, m => m.CreateTime).Text("创建时间").Format("yyyy-MM-dd HH:mm:ss").Width(120),
                    Html.X().Column().DataIndex(Model, m => m.Creator).Text("创建人"),
                    Html.X().Column().DataIndex(Model, m => m.SortNum).Text("序号")
                 )
                .SelectionModel(Html.X().CheckboxSelectionModel().Mode(SelectionMode.Multi))
                .Listeners(ls =>
                {
                    ls.ItemContextMenu.Handler = "e.preventDefault(); App.Grid1CtxMenu.dataRecord = this.store.getAt(index); App.Grid1CtxMenu.showAt(e.getXY());";
                })
                .View(Html.X().GridView().StripeRows(true))
                .DirectEvents(de =>
                {
                    de.ItemDblClick.Action = "EditMenuItemWindow";
                    de.ItemDblClick.ExtraParams.Add(new Parameter("itemId", "record.data['ItemID']", ParameterMode.Raw));
                })
                .TopBar(
                    Html.X().Toolbar()
                        .Items(
                            Html.X().Button().Text("新建菜单项").Icon(Icon.Add).DirectClickAction("NewMenuItemWindow"),
                            Html.X().Button().ID("BtnDeleteSel").Text("删除菜单项").Icon(Icon.Cross)
                                .Listeners(
                                    ls => ls.Click.Fn = "ext.net.comjs.deleteGridSelected"
                                )
                        )
                )
                .BottomBar(
                    Html.X().PagingToolbar()
                        .Items(
                            Html.X().Label("每页显示行数："),
                            Html.X().ToolbarSpacer(10),
                            Html.X().ComboBox()
                                .Width(80)
                                .Items("10", "50", "100")
                                .SelectedItems("50")
                                .Listeners(lr =>
                                {
                                    lr.Select.Fn = "ext.net.comjs.onPageSizeChange";
                                })
                        )
                )
        )
)